package com.example.fontposition.controller;

import cn.tedu.common.pojo.vo.PageData;
import cn.tedu.common.web.JsonResult;
import cn.tedu.zhaopin.protocol.position.vo.PositionSimpleVO;
import com.example.fontposition.pojo.po.PositionPO;
import com.example.fontposition.pojo.po.User;
import com.example.fontposition.pojo.vo.PositionVO;
import com.example.fontposition.service.IPositionService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.Pattern;

@RestController
@Slf4j
//@RequestMapping("/position")
@Validated
@Api(tags = "推荐职位")
@RequestMapping("/search")
public class PositionController {

    @Autowired
    private IPositionService positionService;


    public PositionVO getStandardById( Long userId) {
        log.debug("开始调用ES处理【根据ID查询商品】的请求，参数：", userId);
        PositionVO queryResult = positionService.getId(userId);
        return queryResult;
    }

    @GetMapping("/page")
    @ApiOperation("搜索职位")
    public JsonResult search(User user) {

        System.out.println(user.getPage()+"!!!!!!!!!!!!!");
        Long userId=user.getUserId();
        Integer page=user.getPage();
        PositionVO positionVO = positionService.getId(userId);
        String exceptJob = positionVO.getExceptJob();
        Integer pageNum = page == null ? 1 : page;
        log.debug("开始处理【搜索商品】的请求，关键词：{}"+exceptJob+"，页码：{}"+page );
        PageData<PositionSimpleVO> pageData = positionService.search(exceptJob, pageNum);
        return JsonResult.ok(pageData);
    }

}
